package com.itcodai.dbconnect.aop;

import com.itcodai.dbconnect.bean.DBContextHolder;

/**
 * @author c-fanqj
 * @date 2023/3/29
 * @apiNote 切面类
 */
//@Aspect
//@Component
public class DataSourceAop {

    /*@Pointcut("!@annotation(com.itcodai.dbconnect.annotation.Master) " +
            "&& (execution(* com.itcodai.service..*.select*(..)) " +
            "|| execution(* com.itcodai.service..*.get*(..)) " +
            "|| execution(* com.itcodai.service..*.find*(..)) " +
            "|| execution(* com.itcodai.service..*.query*(..)))")*/
    //@Pointcut("!@annotation(com.itcodai.dbconnect.annotation.Master) " +
     //      "&& @annotation(com.itcodai.dbconnect.annotation.Slaver)")
    public void readPointcut() {

    }

    /*@Pointcut("@annotation(com.itcodai.dbconnect.annotation.Master) " +
            "|| execution(* com.itcodai.service..*.insert*(..)) " +
            "|| execution(* com.itcodai.service..*.add*(..)) " +
            "|| execution(* com.itcodai.service..*.update*(..)) " +
            "|| execution(* com.itcodai.service..*.edit*(..)) " +
            "|| execution(* com.itcodai.service..*.delete*(..)) " +
            "|| execution(* com.itcodai.service..*.remove*(..))")*/
    //@Pointcut("@annotation(com.itcodai.dbconnect.annotation.Master)")
    public void writePointcut() {

    }

    //@Before("readPointcut()")
    public void read() {
        DBContextHolder.slave();
    }

    //@Before("writePointcut()")
    public void write() {
        DBContextHolder.master();
    }

}
